package org.confucianismframework.orm.sql.produce.support;

import org.confucianismframework.orm.enums.SQLType;
import org.confucianismframework.orm.pattern.EntityNamePattern;
import org.confucianismframework.orm.annotation.RegisterSQLStrategy;
import org.confucianismframework.orm.sql.produce.SqlProduce;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

/**
 * 生成 Delete 语句
 *
 * @author zy
 */
@RegisterSQLStrategy(SQLType.DELETE)
public class DeleteSqlProduce implements SqlProduce {

    @Override
    public String produce(Object instance) {

        Class<?> instanceClazz = instance.getClass();

        List<Field> fields = Arrays.asList(instanceClazz.getDeclaredFields());

        String tableName = EntityNamePattern.humpToLine(instanceClazz.getSimpleName());

        String deleteSql = "DELETE FROM " + tableName + " WHERE id=?";

        return deleteSql;
    }

}
